{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加文章</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">标题：</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" name="title" lay-verify="required" placeholder="文章标题">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">所属分类：</label>
                            <div class="layui-input-block">
                                <select name="cate_id" lay-verify="required" lay-search="">
                                    <option value="">请选择分类</option>
                                    {if !empty($cate)}
                                    {foreach name="cate" item="vo"}
                                    <option value="{$vo.id}">{$vo.name}</option>
                                    {/foreach}
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">三级联动</label>
                            <div class="layui-inline test1" lay-filter="test1"></div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">关键字：</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input " name="keyword" lay-verify="required" placeholder="文章关键字">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">描述：</label>
                            <div class="layui-input-block">
                                <textarea name="remark" class="layui-textarea" lay-verify="required" placeholder="文章描述"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">单图片上传：</label>
                            <input type="hidden" name="lay-img" id="lay-img" lay-verify="image">
                            <div class="layui-input-block">
                                <div id="lay-upload">上传图片</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览图：
                                    <div class="layui-upload-list" id="lay-list">
                                    </div>
                                </blockquote>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">单图片上传：</label>
                            <input type="hidden" name="lay-img1" id="lay-img1" lay-verify="image">
                            <div class="layui-input-block">
                                <div id="lay-upload1">上传图片</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览图：
                                    <div class="layui-upload-list" id="lay-list1">
                                    </div>
                                </blockquote>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">音频上传：</label>
                            <input type="hidden" name="lay-music" id="lay-music" lay-verify="music">
                            <div class="layui-input-block">
                                <div id="lay-music-upload">上传音频</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览音频：
                                    <div class="layui-upload-list" id="lay-music-list">
                                    </div>
                                </blockquote>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">音频上传：</label>
                            <input type="hidden" name="lay-music" id="lay-music1" lay-verify="music">
                            <div class="layui-input-block">
                                <div id="lay-music-upload1">上传音频</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览音频：
                                    <div class="layui-upload-list" id="lay-music-list1">
                                    </div>
                                </blockquote>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">多图片上传</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="photo" id="photo" lay-verify="image">
                                <div id="uploader" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker"></div>
                                            <p>或将照片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">多图片上传</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="photo" id="photo1" lay-verify="image">
                                <div id="uploader1" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker1"></div>
                                            <p>或将照片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker1" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">多图片修改</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="del" id="del2" value="">
                                <input type="hidden" id="hid2" value="{$photo}">
                                <input type="hidden" name="photo" id="photo2" value="{$photo}">
                                <div id="uploader2" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker2"></div>
                                            <p>或将照片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker2" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">多图片修改1</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="del" id="del3" value="">
                                <input type="hidden" id="hid3" value="{$photo}">
                                <input type="hidden" name="photo" id="photo3" value="{$photo}">
                                <div id="uploader3" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker3"></div>
                                            <p>或将照片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker3" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">七牛分片上传</label>
                            <div class="layui-input-block" >
                                <input type="hidden" name="video" id="qiniuVideo">
                                <button class="layui-btn" style="position: absolute;">选择文件</button>
                                <input class="file-input" type="file" id="select2"  multiple="multiple" accept="video/mp4,video/avi,vide/mkv"/>
                                <table class="layui-table">
                                    <colgroup>
                                        <col width="80">
                                        <col width="100">
                                        <col width="200">
                                        <col width="100">
                                    </colgroup>
                                    <thead>
                                    <tr>
                                        <th>文件名称</th>
                                        <th>文件大小</th>
                                        <th>进度</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody id="fsUploadProgress">
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">所属分类：</label>
                            <div class="layui-input-block">
                                <select name="cate_id" lay-verify="required" lay-search="">
                                    <option value="">请选择分类</option>
                                    {if !empty($cate)}
                                    {foreach name="cate" item="vo"}
                                    <option value="{$vo.id}">{$vo.name}</option>
                                    {/foreach}
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">王编辑器：</label>
                            <div class="layui-input-block" id="LAY_editor" lay-verify="editor">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">百度编辑器：</label>
                            <div class="layui-input-block" >
                                <textarea name="lay_content" id="LAY_editor2" placeholder="文章描述"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">高德</label>
                            <div class="layui-input-block">
                                <div id="container" style="width:100%;height:500px;margin-bottom:20px;"></div>
                                <div class="layui-inline" style="position: absolute;z-index: 10000;top:20px;right:0px;">
                                    <label class="layui-form-label">搜索</label>
                                    <div class="layui-input-inline">
                                        <input id='tipinput' type="text" class="layui-input" placeholder="请输入关键字">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">地址</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="address" name="address" class="layui-input" placeholder="地址" disabled>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">经度</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="lon" name="lon" class="layui-input" placeholder="经度" disabled>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">纬度</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="lat" name="lat" class="layui-input" placeholder="纬度" disabled>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">百度</label>
                            <div class="layui-input-block">
                                <div id="l-map" style="width:100%;height:500px;margin-bottom:20px;"></div>
                                <div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>
                                <div class="layui-inline" style="position: absolute;z-index: 10000;top:20px;right:0px;">
                                    <label class="layui-form-label">搜索</label>
                                    <div class="layui-input-inline">
                                        <input id='suggestId' type="text" class="layui-input" placeholder="请输入关键字">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">地址</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="address_b" name="address_b" class="layui-input" placeholder="地址" disabled>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">经度</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="lon_b" name="lon_b" class="layui-input" placeholder="经度" disabled>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">纬度</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="lat_b" name="lat_b" class="layui-input" placeholder="纬度" disabled>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">浏览量：</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input " name="views" lay-verify="required" placeholder="文章浏览量" onkeyup="value=value.replace(/[^\d]/g,'')">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">作者：</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input " name="views" lay-verify="required" placeholder="文章作者">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">是否推荐：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="is_tui" value="1" title="是" checked>
                                <input type="radio" name="is_tui" value="2" title="否" >
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<!--—————————————————————七牛云分片上传—————————————————————————-->
<link rel="stylesheet" href="__JS__/qiniu2.0/index.css">
<script type="text/javascript" src='__JS__/qiniu2.0/qiniu.min.js'></script>
<script type="text/javascript" src='__JS__/qiniu2.0/widget.js'></script>
<script type="text/javascript" src='__JS__/qiniu2.0/common.js'></script><!--上传操作-->
<script type="text/javascript" src='__JS__/qiniu2.0/ui.js'></script><!--展示上传表格-->
<script type="text/javascript" src='__JS__/qiniu2.0/uploadWithSDK.js'></script><!--h5上传-->
<script type="text/javascript" src='__JS__/qiniu2.0/main.js'></script><!--调用后台生成token-->
<!--—————————————————————七牛云分片上传—————————————————————————-->


<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.10&key=	b1c2db1116a93d1611b32c9c4d9535ad&plugin=AMap.Autocomplete,AMap.PlaceSearch"></script><!--高德-->
<script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script><!--高德-->

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=KQnMmWiFFe98BhjfhZsM7LlCZ38qlhAv"></script><!--百度-->
<script>

    // 高德
    wk.amap();
    //百度
    wk.bmap();

    /*************************************多图上传**********************************************/
    var n = wk.uploads({num:3,type:'png',url:"{:url('admin/upload/uploadLocality')}"});
    var n1 = wk.uploads({num:4,type:'jpg',attr:1});
    function imgDel(e,obj){
        wk.uploads_del(e,obj,n,"{:url('admin/upload/deleteLocality')}");
    }
    function imgDel1(e,obj){
        wk.uploads_del(e,obj,n1);
    }
    /*************************************多图上传**********************************************/

    /*************************************多图修改**********************************************/
    var n2 = wk.uploads({num:8,type:'png,jpg,gif',attr:2,status:'update',url:"{:url('admin/upload/uploadLocality')}"})
    var n3 = wk.uploads({num:8,type:'png,jpg,gif',attr:3,status:'update',url:"{:url('admin/upload/uploadLocality')}"})
    function imgDel2(e,obj,hid,del){
        wk.update_del(e,obj,hid,del,n2);
    }
    function imgDel3(e,obj,hid,del){
        wk.update_del(e,obj,hid,del,n3);
    }
    /*************************************多图修改**********************************************/
    //百度富文本编辑器
    var ue = wk.UEditor({id:"LAY_editor2",cloud:true,uploadimage:'/admin/Upload/ueditorUpload',uploadscrawl:'/admin/Upload/uploadScrawl',uploadfile:'/admin/Upload/ueditorUpload'});

    //王编辑器
    var editor = wk.wang({elem:'#LAY_editor'});


    wk.uploadImg({size:2,type:'png',url:"{:url('Upload/upload')}",domain:"{:config('qiniu.domain')}"});//单图上传
    wk.uploadImg({size:5,num:1,type:'jpg',url:"{:url('Upload/upload')}",domain:"{:config('qiniu.domain')}"});//单图上传
    wk.uploadMusic({size:100,type:'mp3',url:"{:url('Upload/upload')}",domain:"{:config('qiniu.domain')}"});//音频上传
    wk.uploadMusic({size:100,num:1,type:'mp3',url:"{:url('Upload/upload')}",domain:"{:config('qiniu.domain')}"});//音频上传

    layui.use(['form','upload','interact'], function() {
        var form = layui.form,
            interact = layui.interact

        //interact省市区联动
        interact.render({
            elem : '.test1',//lay-filter="test1"
            title : false,
            pid : 1,//默认1
            data : JSON.parse('{:cache("area_data")}'),//缓存里面的地区数据
            name : 'city',//提交表单的name
            selected : [1177,1178,1197],//默认选中的数据 可为空
            hint : ['请选择省份','请选择城市','请选择区/县'],
        });

        form.verify({
            image:[/\S/,'请上传图片'],
            music:[/\S/,'请上传音频'],
            editor:function(value,item){
                if(editor.txt.html() == '<p><br></p>'){
                    return '请填写内容';
                }
            }
        });
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            data.field.html = editor.txt.html();//获取王编辑器内容
            data.field.ue = ue.getAllHtml();//百度编辑器
            $.ajax({
                url:"{:url('userAdd')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            wk.layer_close();
                        })
                    } else {
                        $(".layui-btn").removeClass('layui-disabled').removeAttr('disabled');
                        wk.error(res.msg);
                        return false;
                    }
                }
            })
        });
    });
</script>
</body>
</html>
